<?php require_once('Connections/morroco.php'); ?>
<?php
if (!isset($_SESSION)) {
  session_start();
}
$MM_authorizedUsers = "";
$MM_donotCheckaccess = "true";

// *** Restrict Access To Page: Grant or deny access to this page
function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) { 
  // For security, start by assuming the visitor is NOT authorized. 
  $isValid = False; 

  // When a visitor has logged into this site, the Session variable MM_Username set equal to their username. 
  // Therefore, we know that a user is NOT logged in if that Session variable is blank. 
  if (!empty($UserName)) { 
    // Besides being logged in, you may restrict access to only certain users based on an ID established when they login. 
    // Parse the strings into arrays. 
    $arrUsers = Explode(",", $strUsers); 
    $arrGroups = Explode(",", $strGroups); 
    if (in_array($UserName, $arrUsers)) { 
      $isValid = true; 
    } 
    // Or, you may restrict access to only certain users based on their username. 
    if (in_array($UserGroup, $arrGroups)) { 
      $isValid = true; 
    } 
    if (($strUsers == "") && true) { 
      $isValid = true; 
    } 
  } 
  return $isValid; 
}

$MM_restrictGoTo = "index.php";
if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {   
  $MM_qsChar = "?";
  $MM_referrer = $_SERVER['PHP_SELF'];
  if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
  if (isset($_SERVER['QUERY_STRING']) && strlen($_SERVER['QUERY_STRING']) > 0) 
  $MM_referrer .= "?" . $_SERVER['QUERY_STRING'];
  $MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
  header("Location: ". $MM_restrictGoTo); 
  exit;
}
?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

$colname_datos_usuario = "-1";
if (isset($_SESSION['MM_Username'])) {
  $colname_datos_usuario = $_SESSION['MM_Username'];
}
mysql_select_db($database_morroco, $morroco);
$query_datos_usuario = sprintf("SELECT * FROM usuarios WHERE nombre = %s", GetSQLValueString($colname_datos_usuario, "text"));
$datos_usuario = mysql_query($query_datos_usuario, $morroco) or die(mysql_error());
$row_datos_usuario = mysql_fetch_assoc($datos_usuario);
$totalRows_datos_usuario = mysql_num_rows($datos_usuario);

$colname_id_usuario_datos_docentes = "-1";
if (isset($row_datos_usuario['ID'])) {
  $colname_id_usuario_datos_docentes = $row_datos_usuario['ID'];
}
mysql_select_db($database_morroco, $morroco);
$query_datos_docentes = sprintf("SELECT * FROM docente WHERE id_usuario = %s", GetSQLValueString($colname_id_usuario_datos_docentes, "int"));
$datos_docentes = mysql_query($query_datos_docentes, $morroco) or die(mysql_error());
$row_datos_docentes = mysql_fetch_assoc($datos_docentes);
$totalRows_datos_docentes = mysql_num_rows($datos_docentes);

$colname_id_usuario_asignaturas = "-1";
if (isset($row_datos_usuario['ID'])) {
  $colname_id_usuario_asignaturas = $row_datos_usuario['ID'];
}
mysql_select_db($database_morroco, $morroco);
$query_asignaturas = sprintf("SELECT * FROM asignatura WHERE id_usuario = %s", GetSQLValueString($colname_id_usuario_asignaturas, "int"));
$asignaturas = mysql_query($query_asignaturas, $morroco) or die(mysql_error());
$row_asignaturas = mysql_fetch_assoc($asignaturas);
$totalRows_asignaturas = mysql_num_rows($asignaturas);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/principal2.dwt.php" codeOutsideHTMLIsLocked="false" -->
<head>
<link rel="icon" type="image/x-icon" href="imagenes/favicon.ico" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- InstanceBeginEditable name="doctitle" -->
<title>Menú</title>
<!-- InstanceEndEditable -->
<!-- InstanceBeginEditable name="head" -->
<script src="SpryAssets/SpryAccordion.js" type="text/javascript"></script>
<script src="SpryAssets/SpryTooltip.js" type="text/javascript"></script>
<link href="SpryAssets/SpryAccordion.css" rel="stylesheet" type="text/css" />
<link href="SpryAssets/SpryTooltip.css" rel="stylesheet" type="text/css" />
<!-- InstanceEndEditable -->
<link href="css/twoColFixLtHdr.css" rel="stylesheet" type="text/css" />
<style type="text/css">
.container .header h1 strong {
	color: #FFF;
}
</style>
</head>

<body>

<div class="container">
  <div class="header">
    <h1>Generador de Horarios</h1>
  <!-- end .header --></div>
  <div class="sidebar1">
    <ul class="nav">
      <li><a href="menu.php">Inicio / Menú</a></li>
    </ul>
    <p><img src="imagenes/morroco.png" width="149" height="94" alt="morroco" /></p>
    <!-- end .sidebar1 --></div>
  <div class="content"> <!-- InstanceBeginEditable name="EditRegion3" -->
<?php include('scripts/funciones.php') ?>
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td align="center" valign="middle"><strong>Inicio -&gt; Menú</strong></td>
      </tr>
    </table>
    <div id="Acordeon" class="Accordion" tabindex="0">
      <div class="AccordionPanel">
        <div class="AccordionPanelTab">[Consulta] Docentes - 
          <input name="agregar_docente" type="button" id="agregar_docente" onclick="window.location.href='docente/agregar.php'" value="Agregar Docente" />
        </div>
        <div class="AccordionPanelContent">
          <?php if ($totalRows_datos_docentes > 0) { // Show if recordset not empty ?>
            <table width="100%" border="1" align="center" cellpadding="0" cellspacing="0">
              <tr>
                <td width="20%" align="center" valign="middle"><strong>ID</strong></td>
                <td width="60%" align="center" valign="middle"><strong>Nombre del Docente</strong></td>
                <td width="20%" align="center" valign="middle"><strong>Eliminar</strong></td>
              </tr>
              <?php do { ?>
        		<tr style="background-color:<?php echo fondolinea($row_datos_docentes['ID']) ?>">
                  <td width="20%"><?php echo $row_datos_docentes['ID']; ?></td>
                  <td width="60%">
                    <label for="editar_docente"></label>
                  <input onclick="window.location.href='docente/editar.php?docente=<?php echo $row_datos_docentes['ID']; ?>'" name="editar_docente" type="text" id="editar_docente" value="<?php echo $row_datos_docentes['nombre']; ?>" size="50" /></td>
                  <td width="20%" align="center"><input name="borrar_asignatura2" type="button" id="borrar_asignatura2" onclick="window.location.href='?docente=" value="X" /></td>
                </tr>
                <?php } while ($row_datos_docentes = mysql_fetch_assoc($datos_docentes)); ?>
            </table>
            <br />
            <?php echo $totalRows_datos_docentes ?> Docentes registrados
            <?php } else { echo "No existen datos registrados, click en Boton Agregar Docente"; }// Show if recordset not empty ?>
        </div>
      </div>
      <div class="AccordionPanel">
        <div class="AccordionPanelTab">[Consulta] Asignaturas -
          <input name="agregar_asignatura" type="submit" id="agregar_asignatura" onclick="window.location.href='asignatura/agregar.php'" value="Agregar Asignatura" />
        </div>
        <?php if ($totalRows_asignaturas > 0) { // Show if recordset not empty ?>
  <div class="AccordionPanelContent">
    <table width="100%" border="1" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td width="20%" align="center"><strong>ID</strong></td>
        <td width="60%" align="center"><strong>Descripción</strong></td>
        <td width="20%" align="center"><strong>Eliminar</strong></td>
      </tr>
      <?php do {  ?>
        <tr style="background-color:<?php echo fondolinea($row_asignaturas['ID']) ?>">
          <td valign="middle"><?php echo $row_asignaturas['ID']; ?><a href="eliminar.php?recordID=<?php echo $row_asignaturas['ID']; ?>"></a></td>
          <td valign="middle"><input name="editar_asignatura" type="text" id="editar_asignatura" onclick="window.location.href='asignatura/editar.php?asignatura=<?php echo $row_asignaturas['ID']; ?>'" value="<?php echo $row_asignaturas['descripcion']; ?>" size="50" /></td>
          <td align="center" valign="middle"><input type="button" name="borrar_asignatura" id="borrar_asignatura" value="X" onclick="window.location.href='?asignatura=<?php echo $row_asignaturas['ID']; ?>'" /></td>
        </tr>
        <?php } while ($row_asignaturas = mysql_fetch_assoc($asignaturas)); ?>
    </table>
    <br />
    <?php echo $totalRows_asignaturas ?> Asignaturas registradas</div>
  <?php } else { echo "No existe Asignaturas registradas, Click en Botón Agregar Asignatura"; }// Show if recordset not empty ?>
      </div>
<div class="AccordionPanel">
        <div class="AccordionPanelTab">[Consulta] Datos de Usuario - ID <?php echo $row_datos_usuario['ID']; ?></div>
        <div class="AccordionPanelContent">
          <form action="usuario/editar.php" method="post">
            <p>Nombre: <?php echo $row_datos_usuario['nombre']; ?></p>
            <p>email: <?php echo $row_datos_usuario['email']; ?></p>
            <p>Descripción: <?php echo $row_datos_usuario['descripcion']; ?></p>
            <p style="text-align:center">
              <input name="id_usuario" type="hidden" id="id_usuario" value="<?php echo $row_datos_usuario['ID']; ?>" />
              <input type="submit" name="editar" id="editar" value="Editar Datos" />
            </p>
          </form>
        </div>
      </div>
<div class="AccordionPanel">
        <div class="AccordionPanelTab">Etiqueta 4</div>
        <div class="AccordionPanelContent">Contenido 4</div>
      </div>
    </div>
    <div class="tooltipContent" id="sprydocente">Click para Editar Nombre del Docente.</div>
    <div class="tooltipContent" id="sprytooltip1">Click para Editar</div>
    <br />
    <br />
    <script type="text/javascript">
var Accordion1 = new Spry.Widget.Accordion("Acordeon");
var sprytooltip1 = new Spry.Widget.Tooltip("sprytooltip1", "#editar_asignatura");
var sprytooltip2 = new Spry.Widget.Tooltip("sprydocente", "#editar_docente");
    </script>
  <!-- InstanceEndEditable -->    
    <!-- end .content --></div>
  <div class="footer">
  <table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td align="center" valign="middle"><a href="http://www.ch0ngu1.com" target="new">www.Ch0nGu1.com</a></td>
  </tr>
</table>
    <!-- end .footer --></div>
  <!-- end .container --></div>
</body>
<!-- InstanceEnd --></html>
<?php
mysql_free_result($datos_docentes);

mysql_free_result($datos_usuario);

mysql_free_result($asignaturas);
?>
